Class GDHandler

Summary

Fully Qualified Name: CodeIgniter\Images\Handlers\GDHandler
Extends: BaseHandler

Description

Image handler for GD package

Methods

Name Description Defined By
__call() Provide access to the Image class' methods if they don't exist on the handler itself. BaseHandler
__construct() Constructor. GDHandler
_crop() Crops the image. GDHandler
_flatten() Flattens transparencies GDHandler
_flip() Flips an image along it's vertical or horizontal axis. GDHandler
_getHeight() Return image height. GDHandler
_getWidth() Return image width. GDHandler
_resize() Resizes the image. GDHandler
convert() Changes the stored image type to indicate the new file format to use when saving. BaseHandler
crop() Crops the image to the desired height and width. If one of the height/width values is not provided, that value will be set the appropriate value based on offsets and image dimensions. BaseHandler
fit() Combine cropping and resizing into a single command. BaseHandler
flatten() Flattens transparencies, default white background BaseHandler
flip() Flips an image either horizontally or vertically. BaseHandler
getEXIF() Retrieve the EXIF information from the image, if possible. Returns an array of the information, or null if nothing can be found. BaseHandler
getFile() Returns the image instance. BaseHandler
getHeight() Return image height. BaseHandler
getResource() Returns the temporary image used during the image processing. BaseHandler
getVersion() Get GD version GDHandler
getWidth() Return image width. BaseHandler
reorient() Reads the EXIF information from the image and modifies the orientation so that displays correctly in the browser. This is especially an issue with images taken by smartphones who always store the image up-right, but set the orientation flag to display it correctly. BaseHandler
resize() Resize the image BaseHandler
rotate() Rotates the image on the current canvas. BaseHandler
save() Saves any changes that have been made to file. If no new filename is provided, the existing image is overwritten, otherwise a copy of the file is made at $target. GDHandler
text() Overlays a string of text over the image. BaseHandler
withFile() Sets another image for this handler to work on. BaseHandler

Method Details

__call()

Provide access to the Image class' methods if they don't exist on the handler itself.

Parameter Name Type Description
$name string
$args array

Returns: mixed

__construct()

Constructor.

Parameter Name Type Description
$config \type

Returns:

_crop()

Crops the image.

Returns: bool|\CodeIgniter\Images\Handlers\GDHandler

_flatten()

Flattens transparencies

Parameter Name Type Description
$red int
$green int
$blue int

Returns: $this

_flip()

Flips an image along it's vertical or horizontal axis.

Parameter Name Type Description
$direction string

Returns: $this

_getHeight()

Return image height.

Returns: int

_getWidth()

Return image width.

Returns: int

_resize()

Resizes the image.

Returns: bool|\CodeIgniter\Images\Handlers\GDHandler

convert()

Changes the stored image type to indicate the new file format to use when saving.

Does not touch the actual resource.

Parameter Name Type Description
$imageType int|null A

Returns: $this

crop()

Crops the image to the desired height and width. If one of the height/width values is not provided, that value will be set the appropriate value based on offsets and image dimensions.

Parameter Name Type Description
$width int|null
$height int|null
$x int|null X-axis
$y int|null Y-axis
$maintainRatio bool
$masterDim string

Returns: mixed

fit()

Combine cropping and resizing into a single command.

Supported positions:

Parameter Name Type Description
$width int
$height int
$position string

Returns: bool

flatten()

Flattens transparencies, default white background

Parameter Name Type Description
$red int
$green int
$blue int

Returns: mixed

flip()

Flips an image either horizontally or vertically.

Parameter Name Type Description
$dir string Either

Returns: $this

getEXIF()

Retrieve the EXIF information from the image, if possible. Returns an array of the information, or null if nothing can be found.

EXIF data is only supported fr JPEG & TIFF formats.

Parameter Name Type Description
$key string|null If
$silent bool If

Returns: mixed

getFile()

Returns the image instance.

Returns: \CodeIgniter\Images\Image

getHeight()

Return image height.

accessor for testing; not part of interface

Returns: \type

getResource()

Returns the temporary image used during the image processing.

Good for extending the system or doing things this library is not intended to do.

Returns: resource

getVersion()

Get GD version

Returns: mixed

getWidth()

Return image width.

accessor for testing; not part of interface

Returns: int

reorient()

Reads the EXIF information from the image and modifies the orientation so that displays correctly in the browser. This is especially an issue with images taken by smartphones who always store the image up-right, but set the orientation flag to display it correctly.

Parameter Name Type Description
$silent bool If

Returns: $this

resize()

Resize the image

Parameter Name Type Description
$width int
$height int
$maintainRatio bool If
$masterDim string

Returns: \BaseHandler

rotate()

Rotates the image on the current canvas.

Parameter Name Type Description
$angle float

Returns: mixed

save()

Saves any changes that have been made to file. If no new filename is provided, the existing image is overwritten, otherwise a copy of the file is made at $target.

Example: $image->resize(100, 200, true)

  ->save();
Parameter Name Type Description
$target string|null
$quality int

Returns: bool

text()

Overlays a string of text over the image.

Valid options:

Parameter Name Type Description
$text string
$options array

Returns: $this

withFile()

Sets another image for this handler to work on.

Keeps us from needing to continually instantiate the handler.

Parameter Name Type Description
$path string

Returns: $this

Top